package com.mrd.shiptask_shipowner.shiareutil;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;

public class SharePreferenceUtil {
	private final SharedPreferences sp; // 轻量级的存储类,，特别适合用于保存软件配置参数。使用SharedPreferences保存数据，其背后是用xml文件存放数据
	private final SharedPreferences.Editor editor; // 获取编辑器

	public SharePreferenceUtil(Context context, String file) {
		sp = context.getSharedPreferences(file, Context.MODE_PRIVATE);
		editor = sp.edit();
	}

	@SuppressLint("CommitPrefEdits")
	public SharePreferenceUtil(Context context) {
		sp = context.getSharedPreferences("CHUANHUO_E", Context.MODE_PRIVATE);
		editor = sp.edit();
	}

	// 登录账号
	public void setLoginAccount(String LoginAccount) {
		editor.putString("LoginAccount", LoginAccount);
		editor.commit();
	}

	public String getLoginAccount() {
		return sp.getString("LoginAccount", "");
	}

	// 登录密码
	public void setLoginPasswd(String LoginPasswd) {
		editor.putString("LoginPasswd", LoginPasswd);
		editor.commit();
	}

	public String getLoginPasswd() {
		return sp.getString("LoginPasswd", "");
	}

	/**
	 * 机器唯一标识
	 * 
	 * @param uuid
	 */
	public void setUUID(String uuid) {
		editor.putString("device_uuid", uuid);
		editor.commit();
	}

	public String getUUID() {
		return sp.getString("device_uuid", "");
	}

	// 用户的id
	public void setId(String id) {
		editor.putString("id", id);
		editor.commit();
	}

	public String getId() {
		return sp.getString("id", "");
	}

	// 用户的密码
	public void setPasswd(String passwd) {
		editor.putString("passwd", passwd);
		editor.commit();
	}

	public String getPasswd() {
		return sp.getString("passwd", "");
	}

	/**
	 * 船舶名称
	 * 
	 * @return
	 */
	public String getShip_name() {
		return sp.getString("ship_name", "");
	}

	public void setShip_name(String ship_name) {
		editor.putString("ship_name", ship_name);
		editor.commit();
	}

	/**
	 * 船舶id
	 * 
	 * @return
	 */
	public String getShip_id() {
		return sp.getString("ship_id", "");
	}

	public void setShip_id(String ship_id) {
		editor.putString("ship_id", ship_id);
		editor.commit();
	}

	/**
	 * 新建或者编辑船源id预存
	 */
	public void setShipOrderTaskId(String ShipOrderTaskId) {
		editor.putString("ShipOrderTaskId", ShipOrderTaskId);
		editor.commit();
	}

	public String getShipOrderTaskId() {
		return sp.getString("ShipOrderTaskId", "");
	}

	/**
	 * 港口信息是否以获取过
	 */
	public boolean getIsGetDataOfPorts() {
		return sp.getBoolean("IsGetDataOfPorts", false);
	}

	public void setIsGetDataOfPorts(boolean IsGetDataOfPorts) {
		editor.putBoolean("IsGetDataOfPorts", IsGetDataOfPorts);
		editor.commit();
	}

	/**
	 * 船东资料，联系人
	 */
	public void setShipOwnerName(String ShipOwnerName) {
		editor.putString("ShipOwnerName", ShipOwnerName);
		editor.commit();
	}

	public String getShipOwnerName() {
		return sp.getString("ShipOwnerName", "");
	}

	/**
	 * 船东资料，联系方式
	 */
	public void setShipOwnerPhone(String ShipOwnerPhone) {
		editor.putString("ShipOwnerPhone", ShipOwnerPhone);
		editor.commit();
	}

	public String getShipOwnerPhone() {
		return sp.getString("ShipOwnerPhone", "");
	}

	/**
	 * token
	 */
	public void setPushToken(String PushToken) {
		editor.putString("PushToken", PushToken);
		editor.commit();
	}

	public String getPushToken() {
		return sp.getString("PushToken", "");
	}

	/**
	 * 未查看消息数
	 */
	public void setMessageCount(String MessageCount) {
		editor.putString("MessageCount", MessageCount);
		editor.commit();
	}

	public String getMessageCount() {
		return sp.getString("MessageCount", "");
	}

	/**
	 * 货主撤回修改次数
	 */
	public void setRedoCount(String redoCount) {
		editor.putString("redoCount", redoCount);
		editor.commit();
	}

	public String getRedoCount() {
		return sp.getString("redoCount", "");
	}
}
